import sqlite3
import os
from multiprocessing import Process

def worker(name):
    conn = sqlite3.connect(':memory:')
    c = conn.cursor()
    c.execute('CREATE TABLE test (id INTEGER)')
    c.execute('INSERT INTO test VALUES (1)')
    conn.commit()
    c.execute('SELECT * FROM test')
    print(f"进程 {name} (PID: {os.getpid()}) 数据: {c.fetchall()}")
    conn.close()

if __name__ == '__main__':
    p1 = Process(target=worker, args=('A',))
    p2 = Process(target=worker, args=('B',))
    p1.start()
    p2.start()
    p1.join()
    p2.join()